package hibernate;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HelperSessionFactory {
	
    private static SessionFactory sessionFactory;

	private static SessionFactory configureSessionFactory() {
    	try {
    		//Configuration cfg = new Configuration();
    		sessionFactory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
    	} catch (Throwable ex) {
       	 System.err.println("Failed to create sessionFactory object"+ ex);
         throw new ExceptionInInitializerError(ex);
     }
	 return sessionFactory;
}
       
	
	 public static SessionFactory GetSessionFactory()
	    {
	         if (sessionFactory == null)
	         {
	        	 sessionFactory = configureSessionFactory();    
	         }
	         return sessionFactory;
	    }	    
}